<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    function datePrase(){
        var d = new Date();
        // 处理月份
        var m = d.getMonth() + 1;
        // 获取周，处理周
        var day = d.getDay();
        switch(day){
            case 0: day = "日";break;
            case 1: day = "一";break;
            case 2: day = "二";break;
            case 3: day = "三";break;
            case 4: day = "四";break;
            case 5: day = "五";break;
            case 6: day = "六";break;
        }
        // 处理补零，并直接返回对象，内含各个数据
        return {
            year: d.getFullYear(),
            mont: createZero(m),
            date: createZero(d.getDate()),
            day: day,
            hour: createZero(d.getHours()),
            minu: createZero(d.getMinutes()),
            seco: createZero(d.getSeconds()),
            mill: d.getMilliseconds()
        }
    }

    // console.log( datePrase() );


    function createZero(n){
        // 字符或数值都可处理补零
        // 字符：十六进制字符
        // 数值：非NaN正常数值
        if( n.length < 2 || n < 10 ){
            return "0" + n;
        }
        return n;
    }
    
</script>
</html>